package com.ruoyi.biz.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.biz.domain.BizSimilarityResult;
import com.ruoyi.biz.service.IBizSimilarityResultService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 查重结果Controller
 * 
 * @author ruoyi
 * @date 2025-02-26
 */
@RestController
@RequestMapping("/biz/similarityResult")
@Slf4j
public class BizSimilarityResultController extends BaseController
{
    @Autowired
    private IBizSimilarityResultService bizSimilarityResultService;


    /*
    * 查询查重结果统计  根据作业提交id查询
    * */
    @GetMapping("/count/{workSubmitId}")
    public AjaxResult countResult(@PathVariable Long workSubmitId){
        log.info("查询结果统计,{}",workSubmitId);
        return AjaxResult.success(bizSimilarityResultService.selectByWorkSubmitId(workSubmitId));
    }

    /**
     * 查询查重结果列表
     */
    @PreAuthorize("@ss.hasPermi('biz:similarityResult:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizSimilarityResult bizSimilarityResult)
    {
        startPage();
        List<BizSimilarityResult> list = bizSimilarityResultService.selectBizSimilarityResultList(bizSimilarityResult);
        return getDataTable(list);
    }

    /**
     * 导出查重结果列表
     */
    @PreAuthorize("@ss.hasPermi('biz:similarityResult:export')")
    @Log(title = "查重结果", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BizSimilarityResult bizSimilarityResult)
    {
        List<BizSimilarityResult> list = bizSimilarityResultService.selectBizSimilarityResultList(bizSimilarityResult);
        ExcelUtil<BizSimilarityResult> util = new ExcelUtil<BizSimilarityResult>(BizSimilarityResult.class);
        util.exportExcel(response, list, "查重结果数据");
    }

    /**
     * 获取查重结果详细信息
     */
    @PreAuthorize("@ss.hasPermi('biz:similarityResult:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bizSimilarityResultService.selectBizSimilarityResultById(id));
    }

    /**
     * 新增查重结果
     */
    @PreAuthorize("@ss.hasPermi('biz:similarityResult:add')")
    @Log(title = "查重结果", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizSimilarityResult bizSimilarityResult)
    {
        return toAjax(bizSimilarityResultService.insertBizSimilarityResult(bizSimilarityResult));
    }

    /**
     * 修改查重结果
     */
    @PreAuthorize("@ss.hasPermi('biz:similarityResult:edit')")
    @Log(title = "查重结果", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizSimilarityResult bizSimilarityResult)
    {
        return toAjax(bizSimilarityResultService.updateBizSimilarityResult(bizSimilarityResult));
    }

    /**
     * 删除查重结果
     */
    @PreAuthorize("@ss.hasPermi('biz:similarityResult:remove')")
    @Log(title = "查重结果", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bizSimilarityResultService.deleteBizSimilarityResultByIds(ids));
    }
}
